package speedball.speedup;

import javafx.animation.AnimationTimer;
import javafx.scene.control.Label;

public class SpeedUpAnimationTimer extends AnimationTimer {

    private Label text;
    private Integer textValue;
    private Integer preTextValue;

    public SpeedUpAnimationTimer(Label text){
        if(text.getText()==""){
            throw new NullPointerException("null");
        }
        textValue=Integer.valueOf(text.getText());
        preTextValue=textValue;
        this.text=text;
    }

    @Override
    public void handle(long now) {

        textValue++;
        text.setText(textValue.toString());
        if(textValue.intValue()==preTextValue.intValue()){
            super.stop();
        }
    }

    public void start() {
        textValue=0;
        text.setText(textValue.toString());
        super.start();

    }
}
